/* See LICENSE file for copyright and license details. */

/* appearance */
static const unsigned int borderpx  = 2;        /* border pixel of windows */
static const unsigned int snap      = 32;       /* snap pixel */
static const unsigned int systraypinning = 0;   /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
static const unsigned int systrayspacing = 2;   /* systray spacing */
static const int systraypinningfailfirst = 1;   /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/

static const unsigned int gappx     = 12;       /* gap pixel between windows */
static const int showsystray        = 1;     /* 0 means no systray */
static const int showbar            = 1;        /* 0 means no bar */
static const int topbar             = 1;        /* 0 means bottom bar */
#define ICONSIZE 20   /* icon size */
#define ICONSPACING 5 /* space between icon and title */
static const Bool viewontag         = True;     /* Switch view on tag switch */
static const char *fonts[]          = { "WenQuanYi Micro Hei:size=14","WenQuanYi Zen Hei:size=12" };
static const char dmenufont[]       = "Fira Code:size=14";
// Using Colorscheme
static const char col_gray1[] = "#a89984";
static const char col_gray2[] = "#282828";
static const char col_gray3[] = "#FB966e";

static const char col_gray4[] = "#282828";
static const char col_cyan[] = "#FEDFE1";
static const char col_yellow[] = "#a89984";

static const char urg_fg[] = "#a89984";
static const char urg_bg[] = "#cc241d";
static const char urg_border[] = "#b8bb26";

static const char title_fg[] = "#b8bb26";
static const char title_bg[] = "#3A3A3A";

static const char col_borderbar[]   = "#FB966e";


static const char *colors[][3]      = {
    /*               fg           bg         border                         */
    [SchemeNorm] = { col_gray2,     col_gray3,   col_gray1 }, // unfocused wins
    [SchemeSel]  = { col_gray4,      col_cyan,    col_yellow },  // the focused win
    [SchemeHid] =  { urg_fg,      urg_bg,    urg_border },
    [SchemeTitle] = { title_fg,   title_bg,  col_gray3 },
};
// origin color themes
// static const char col_gray1[]       = "#222222";
// static const char col_gray2[]       = "#444444";
// static const char col_gray3[]       = "#bbbbbb";
// static const char col_gray4[]       = "#eeeeee";
// static const char col_cyan[]        = "#005577";
// static const char col_yellow[]        = "#b38f00";
// static const char *colors[][3]      = {
// 	/*               fg         bg         border   */
// 	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
// 	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
// 	[SchemeHid]  = { col_cyan,  col_gray1, col_cyan  },
// 	[SchemeTitle]  = { col_yellow, col_cyan,  col_cyan  },
// };

/* tagging */
//static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

static const char *tags[] = { "\uf126", "\ue780", "\uf66a", "::", "<++>", "^^", "--", "\ue61b", "\ue62b" };
static const Rule rules[] = {
	/* xprop(1):
	 *	WM_CLASS(STRING) = instance, class
	 *	WM_NAME(STRING) = title
	 */
	/* class      instance    title       tags mask     isfloating   monitor */
/*	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
	{ "Conky",     NULL,       NULL,       0,            1,           -1 },
	{ "Tilda",     NULL,       NULL,       0,            1,           -1 },
{ "Firefox",  NULL,       NULL,       1 << 1,       False,       -1 },
	{ "Wps",  NULL,       NULL,       1 << 2,       False,       -1 },
	{ "Wpp",  NULL,       NULL,       1 << 2,       False,       -1 },
	{ "Et",  NULL,       NULL,       1 << 2,       False,       -1 },
	{ "Thunderbird",  NULL,       NULL,       1 << 4,       False,       -1 },
	*/
	{ "Gimp",     NULL,       NULL,       1<<3,    0,       -1 },
	{ "Dia",     NULL,       NULL,          1<<3,    0,       -1 },
	{ "wps",     NULL,       NULL,         1<<2,    0,       -1 },
	{ "Wps",     NULL,       NULL,           1<<2,    0,       -1 },
	{ "et",     NULL,       NULL,          1<<2,    0,       -1 },
	{ "Et",     NULL,       NULL,          1<<2,    0,       -1 },
	{ "wpp",     NULL,       NULL,         1<<2,    0,       -1 },
	{ "Wpp",     NULL,       NULL,      1<<2,    0,       -1 },
	{ "Deadbeef",     NULL,       NULL,       1<<3,            0,           -1 },
	{ "Google-chrome",     NULL,       NULL,       1<<1,            0,           -1 },
	{ "Microsoft-edge",     NULL,       NULL,       1<<1,            0,           -1 },
	{ NULL,       NULL,   "scratchpad",   0,            1,           -1,       's' },
	{ NULL,       NULL,   "translate",   0,            1,           -1,       's' },
	{ NULL,       NULL,   "fzfrun",   0,            1,           -1,       's' },
	{ "Sxiv",       NULL,   NULL,   0,            1,           -1,       's' },
};
/* layout(s) */
static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster     = 1;    /* number of clients in master area */
static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */

static const Layout layouts[] = {
	/* symbol     arrange function */
	{ "[]=",      tile },    /* first entry is default */
	{ "><>",      NULL },    /* no layout function means floating behavior */
	{ "[M]",      monocle },
	{ "[D]",      deck },
};
//static const char *scratchpadcmd[] = {"s", "alacritty", "-t", "scratchpad", "--config-file", "/home/lincoo/.config/alacritty/alacritty-scrachpad.yml", NULL}; 
static const char *scratchpadcmd[] = {"s", "st", "-t", "scratchpad", "-g", "140x20+180", NULL}; 
#include "shiftview.c"
/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
	{ MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
	{ MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
	{ MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },

/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }

/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-b", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[]  = { "st", NULL };
static const char *click1[]  = { "xdotool", "click", "1", NULL };
static const char *click4[]  = { "xdotool", "click", "4", NULL };
static const char *click5[]  = { "xdotool", "click", "5", NULL };
static const char *mouse_left[]  = { "xdotool", "mousemove_relative", "--", "-30", "0", NULL };
static const char *mouse_right[]  = { "xdotool", "mousemove_relative", "--", "30", "0", NULL };
static const char *mouse_up[]  = { "xdotool", "mousemove_relative", "0", "-30", "--", NULL };
static const char *mouse_down[]  = { "xdotool", "mousemove_relative", "0", "30", "--", NULL };
static const char *centerpad[]  = {"/home/lincoo/.i3/script/center.sh", NULL };
//static const char *i3lockcmd[]  = {"i3lock", "-c", "000000", NULL };
//static const char *trayer[]  = {"/home/lincoo/software/dwmscript/tray.sh", NULL };
// static const char *rofishow[]  = {"rofi", "-show", "drun", "-theme", "/home/lincoo/.i3/script/rofi.rasi", "-run-command", NULL };
static const char *rofishow[]  = {"/home/lincoo/.config/rofi/launchers/ribbon/launcher.sh",  NULL };
static const char *clipmenu[]  = {"clipmenu", "-b", "-i", "-fn", "Terminus:size=12", NULL };
static const char *layoutmenu_cmd="layoutmenu.sh";
#include "nextprev.c"

static Key keys[] = {
	/* modifier                     key        function        argument */
	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
	{ MODKEY,                       XK_v,      winview,        {0} },
	{ MODKEY,		XK_slash,		spawn,		SHCMD("~/.i3/script/dswitcher/dswitcher") }, 
	{ MODKEY,		XK_q,		spawn,		SHCMD("rofi -show file-browser-extended -file-browser-resume -theme /home/lincoo/.config/rofi/file-browser/slate_left.rasi") }, 

	{ MODKEY,		XK_o,		spawn,		SHCMD("xmouseless") }, 
	{ MODKEY,                       XK_i,  togglescratch,  {.v = scratchpadcmd } }, //scrachpad hotkey
	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
//	{ MODKEY|ShiftMask,             XK_l,      spawn,          {.v = i3lockcmd } },
	{ MODKEY,             XK_y,      spawn,  SHCMD("clipmenu -i -fn Terminus:size=16 -nb '#002b36' -nf '#839496' -sb '#073642' -sf '#93a1a1'") },
    { MODKEY,             XK_e,      aspectresize,   {.i = +24} },
	  { MODKEY|ShiftMask,             XK_e,      aspectresize,   {.i = -24} },

	{ MODKEY,             XK_minus,      setcfact,       {.f = +0.25} },
	{ MODKEY,             XK_equal,      setcfact,       {.f = -0.25} },
	{ MODKEY,             XK_u,      setcfact,       {.f =  0.00} },
	{ MODKEY,           XK_w,  spawn,          {.v = centerpad  } },
//	{ MODKEY,           XK_Henkan_Mode,  spawn,          {.v = centerpad  } },
	{ MODKEY,             XK_d, spawn,          {.v = rofishow } },
//	{ Mod1Mask,             XK_Tab,  focusstackvis,  {.i = +1 } },
	{ Mod1Mask,             XK_Tab,  swapfocus,  {.i = +1 } },
	{ MODKEY,              XK_z,           view_adjacent,  { .i = +1 } },
	{ MODKEY|ShiftMask,              XK_z,           view_adjacent,  { .i = -1 } },
	{ MODKEY,              XK_n,           shiftview,  { .i = -1 } },
	{ MODKEY|ShiftMask,              XK_n,           shiftview,  { .i = 1 } },
	//移动窗口 配合自由layout 和r 及 e键放大和缩小窗口
	{ MODKEY|ShiftMask,                       XK_a,   moveresize,     {.v = "0x 25y 0w 0h" } },
	{ MODKEY|ShiftMask,                       XK_s,     moveresize,     {.v = "0x -25y 0w 0h" } },
	{ MODKEY|ShiftMask,                       XK_f,  moveresize,     {.v = "25x 0y 0w 0h" } },
	{ MODKEY|ShiftMask,                       XK_d,   moveresize,     {.v = "-25x 0y 0w 0h" } },
	{ MODKEY|ShiftMask,             XK_Down,   moveresize,     {.v = "0x 0y 0w 25h" } },
	//鼠标控制start
	/* mouse virtual*/
	{ MODKEY|ControlMask,             XK_h, spawn,          {.v = click1 } },
	{ MODKEY|ShiftMask,             XK_u, spawn,          {.v = click4 } },
	{ MODKEY|ShiftMask,             XK_i, spawn,          {.v = click5 } },
	{ MODKEY,                       XK_Up,  spawn,  {.v = mouse_up } },
	{ MODKEY,                       XK_Down,  spawn,  {.v = mouse_down } },
	{ MODKEY,                       XK_Left,  spawn,  {.v = mouse_left } },
	{ MODKEY,                       XK_Right,  spawn,  {.v = mouse_right } },
	//鼠标控制end
	//音量控制start
	 { MODKEY|ControlMask,		XK_j,		spawn,		SHCMD("amixer set Master 5%- unmute") }, 
	 { MODKEY|ControlMask,		XK_k,		spawn,		SHCMD("amixer set Master 5%+ unmute") }, 
	//在不同屏幕移动窗口
	 { MODKEY|ShiftMask,		XK_Right,		spawn,		SHCMD("xdotool key Super_L+Shift+comma && xdotool key Super_L+comma") }, 
	 { MODKEY|ShiftMask,		XK_Left,		spawn,		SHCMD("xdotool key Super_L+Shift+period && xdotool key Super_L+period") }, 
	//音量控制end
	{ MODKEY,			XK_s,		togglesticky,	{0} },
	{ MODKEY,                       XK_b,      togglebar,      {0} },
	{ MODKEY,                       XK_j,      focusstackvis,  {.i = +1 } },
	{ MODKEY,                       XK_k,      focusstackvis,  {.i = -1 } },
	{ MODKEY|ShiftMask,             XK_j,      focusstackhid,  {.i = +1 } },
	{ MODKEY|ShiftMask,             XK_k,      focusstackhid,  {.i = -1 } },
	{ MODKEY,                       XK_a,      incnmaster,     {.i = +1 } },
	{ MODKEY|ShiftMask,                       XK_a,      incnmaster,     {.i = -1 } },
	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
	{ MODKEY|ShiftMask,                       XK_l,      setmfact,       {.f = +0.05} },
	{ MODKEY,                       XK_Return, zoom,           {0} },
	{ MODKEY,                       XK_Tab,    view,           {0} },
	{ MODKEY,            		XK_F4,      killclient,     {0} },
	{ MODKEY|ShiftMask,            		XK_c,      killclient,     {0} },
	// { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
	// { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
	{ MODKEY,                       XK_Escape,      layoutmenu,      {0} },
	{ MODKEY,                       XK_space,  setlayout,      {0} },
	// { MODKEY,                       XK_r,      setlayout,      {.v = &layouts[3]} },
	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
//	{ MODKEY|ShiftMask,             XK_f,      togglefullscr,  {0} },
	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
	{ MODKEY|ShiftMask,                       XK_g,      show,           {0} },
	{ MODKEY,                       XK_g,      hide,           {0} },
	TAGKEYS(                        XK_1,                      0)
	TAGKEYS(                        XK_2,                      1)
	TAGKEYS(                        XK_3,                      2)
	TAGKEYS(                        XK_4,                      3)
	TAGKEYS(                        XK_5,                      4)
	TAGKEYS(                        XK_6,                      5)
	TAGKEYS(                        XK_7,                      6)
	TAGKEYS(                        XK_8,                      7)
	TAGKEYS(                        XK_9,                      8)
	{ MODKEY|ShiftMask,             XK_q,      quit,           {0} },
};

/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
	/* click                event mask      button          function        argument */
	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
	{ ClkWinTitle,          0,              Button1,        togglewin,      {0} },
	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
	{ ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
	{ ClkTagBar,            0,              Button1,        view,           {0} },
	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
};

